package com.ruoyi.flow.common.tools.mediaconverter.converter.reflections.scanners;

import java.lang.reflect.Field;
import java.util.List;

import com.ruoyi.flow.common.tools.mediaconverter.converter.reflections.util.JavaReflectionUtils;

/** scans for field's annotations */
@SuppressWarnings({"unchecked"})
public class FieldAnnotationsScanner extends AbstractScanner {
    public void scan(final Class cls) {
        final String className = JavaReflectionUtils.getClassName(cls);
        List<Field> fields = JavaReflectionUtils.getFields(cls);
        for (final Field field : fields) {
            List<String> fieldAnnotations = JavaReflectionUtils.getFieldAnnotationNames(field);
            for (String fieldAnnotation : fieldAnnotations) {

                if (acceptResult(fieldAnnotation)) {
                    String fieldName = JavaReflectionUtils.getFieldName(field);
                    getStore().put(fieldAnnotation, String.format("%s.%s", className, fieldName));
                }
            }
        }
    }
}
